<template>
	<view class="ys">
		<view class="newsdetail">
			<view class="title">
				{{info.title}}
			</view>
			<view class="time">
				<text>发布时间：{{info.release_time || info.add_time}}</text>
			</view>
			<view class="content" v-html="getContent(info.content)">

			</view>
			<view class="goodsbox" v-if="info.goods" @click="toPage('/pages/goodsdetail/index?id='+info.goods_id)">
				<view class="imgbox">
					<image :src="info.goods.cover_path" mode="aspectFill"></image>
				</view>
				<view class="info">
					<view class="name">
						{{info.goods.name}}
					</view>
					<view class="desc">
						{{info.goods.sketch || ''}}
					</view>
					<view class="price">
						￥{{info.goods.price}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		NoticeDetail
	} from "@/api/api.js"
	export default {
		data() {
			return {
				info: [],
				id: '',
				goods: []
			}
		},
		onLoad(e) {
			if (e.id) {
				this.id = e.id
			}
			this.NoticeDetail()
		},
		methods: {
			getContent(content) {
				if (typeof(content) == 'string')
					return content.replace(/<img src="/g,
						'<img style="border-radius: 8px;max-width:100%;width:100%;display:block;" src="' +
						this.$config.websiteUrl)
			},
			NoticeDetail() {
				NoticeDetail({
					id: this.id
				}).then(res => {
					this.info = res.data

				})
			},
		}
	}
</script>

<style lang="scss">
	.ys {
		padding-top: 20px;
		min-height: calc(100vh);
		/* #ifdef H5 */
		min-height: calc(100vh - 44px);
		/* #endif */
		height: 100%;
		background: linear-gradient(180deg, #E6EAFA, #F4F8FB);
		padding-bottom: 1px;
		box-sizing: border-box;

		.goodsbox {
			position: fixed;
			bottom: 20px;
			background: #fff;
			width: 96%;
			left: 50%;
			transform: translate(-50%);
			padding: 10px;
			box-sizing: border-box;
			border-radius: 8px;
			display: flex;
			align-items: center;

			.imgbox {
				image {
					width: 60px;
					height: 60px;
				}
			}

			.info {
				width: calc(100% - 60px);
				padding-left: 10px;
				box-sizing: border-box;

				.name {
					font-size: 14px;
					font-weight: bold;
					margin-bottom: 3px;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.desc {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					color: #777;
					font-size: 12px;
				}

				.price {
					color: #E0C03F;
					font-weight: bold;
					font-size: 17px;
					margin-top: 3px;
				}
			}
		}

		.newsdetail {
			border-radius: 10px;
			background: #FFFFFF80;
			width: 96%;
			margin: 0 auto;
			box-sizing: border-box;
			padding: 20px;

			.title {
				font-size: 20px;
				font-weight: bold;
				line-height: 30px;
				vertical-align: top;
				color: #333;
			}

			.time {
				display: flex;
				justify-content: space-around;
				font-size: 13px;
				color: #bdbdbd;
				margin: 15px auto;
			}


		}
	}
</style>